package com.muyu.rabbitmqdemo.sender;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName: RabbitSender
 * @Author: Zirun.Xin
 * @Date: 2025/4/9 上午9:20
 * @Version: 1.0
 * @Description: rabbitMQ生产者
 */
@Slf4j
@Component
public class RabbitSender {

    /**
     * AMQP协议 Template
     */
    @Autowired
    private AmqpTemplate amqpTemplate;

    /**
     * 发送消息
     */
    public void sendMsg() {
        String msg = "简单队列-hello呀";
        log.info("Sender：{}", msg);
        this.amqpTemplate.convertAndSend("test1-queue", msg);
    }
}
